home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / actlib13.zip / STRINGS.ZIP / SKIP.C < prev    next >
Text File  |  1993-01-14  |  806b  |  35 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. #include "strings.h"
  4.  
  5. /***
  6.  *  Function    :   strskip
  7.  *
  8.  *  Description :   Skip 'n' words from a string.
  9.  *
  10.  *  Decisions   :
  11.  *
  12.  *  Parameters  :   in    char    *string     string to be matched
  13.  *                  in    int     word_nb     number of words to skip
  14.  *
  15.  *  Return code :   pointer to word.
  16.  *
  17.  *  OS/Compiler :   All
  18.  ***/
  19.  
  20. char *strskip( const char *string, int word_nb )
  21.  
  22. { char *ptr;
  23.  
  24.   while ( *string == ' ' || *string == '\n' || *string == '\t' ) string++;
  25.  
  26.   for ( ; word_nb; word_nb-- )
  27.       {
  28.         ptr = strpbrk( string, " \n\t" );
  29.         if ( ptr ) string = ptr + strspn( ptr, " \n\t" );
  30.               else while ( *string ) string++;
  31.       }
  32.  
  33. return string;
  34. }
  35.